/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package DBFunction;

import java.sql.ResultSet;
import java.sql.SQLException;

public class fLogin {
	public static String check(String username, String password) {
		String sql = "SELECT PhoneNumber, Passwords,GroupId,IsOnline FROM buddytracking.user where user.PhoneNumber='"
				+ username + "' and user.Passwords='" + password + "'";
		ResultSet resultSet = DB.connectDB.ExecuteQuery(sql);
		String result = "wrong";
		try {
			while (resultSet.next()) {			
					if (resultSet.getString("PhoneNumber").equals(username)
							&& resultSet.getString("Passwords")
									.equals(password)) {
						if(resultSet.getString("GroupId").equals("0"))
							result = "is_inactive";
						else if(resultSet.getString("IsOnline").equals("1"))
							result = "is_online";
						else if(resultSet.getString("IsOnline").equals("0"))
							result = "right";						
					}
				}
		} catch (SQLException ex) {
		}
		return result;
	}
}
